package junitTest;

import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvFileSource;
import org.junit.jupiter.params.provider.CsvSource;

import java.text.ParseException;

import static org.junit.jupiter.api.Assertions.assertEquals;
public class TriangleTest {
    @Test
    @DisplayName(value="一般三角形")
    void testTriangle() {
        Triangle triangle = new Triangle();

        String type = triangle.classify(3, 4, 6);
        assertEquals("一般三角形", type);
    }
    @Test
    @DisplayName(value="等腰三角形")
    void IsoscelesTriangle(){
        Triangle triangle = new Triangle();
        String type = triangle.classify(3,4,3);
        assertEquals("等腰三角形",type);
    }
    @Test
    @DisplayName(value="等边三角形")
    void equallaterialTriangle() {
        Triangle triangle = new Triangle();

        String type = triangle.classify(3, 3, 3);
        assertEquals("等边三角形", type);
    }
    @Test
    @DisplayName(value="非三角形")
    void notTriangle() {
        Triangle triangle = new Triangle();

        String type = triangle.classify(3, 3, 6);
        assertEquals("非三角形", type);
    }

    @ParameterizedTest
    @CsvSource({
            "3,4,6,一般三角形",
            "3,3,3,等边三角形",
            "3,3,6,非三角形"
    })
    void paramTriangle(int a, int b,int c,String expected) {
        Triangle triangle = new Triangle();

        String type = triangle.classify(a, b, c);

        assertEquals(expected, type);
    }
    @Test
    @DisplayName(value="输入错误")
    public void testInputErrorNegative() {
        // 测试输入错误（负数）
        Triangle triangle = new Triangle();
        String result =triangle.classify(-1,2,3);
        assertEquals("输入错误", result);
    }
    }
